<template>
  <div class="body">
    <div id="loginDiv">
        <form id="form">
            <h1 style="color:white;">登陆</h1>
           <span>账号:</span><input type="text" placeholder="请输入账号" v-model="ruleForm.userUsername">
           <br><br>
           <span>密码:</span><input type="password" placeholder="请输入密码" v-model="ruleForm.userPassword">
      
            <div style="text-align: center;margin-top: 30px;">
                <button type="button" class="button" @click="SubmitForm">登录</button>
                <router-link to="/register"><input type="reset" class="button" value="注册"></router-link>
            </div>
        </form>
    </div>

</div>
</template>

<script>
export default {
  name: "HelloWorld",
  data(){
      return{
          ruleForm:{
              userUsername:'',
             userPassword:''
          }
           
        }
  },
  methods:{
      SubmitForm(){
          this.$axios.post('http://localhost:8888/api/news',this.ruleForm).then(res => {

          if(res.data.data.status==true)
             {
               this.$router.push({path: "/recommend"})
                this.$notify({
                 message: '恭喜您，登录成功',
                 });
            this.$store.state.username = this.ruleForm.userUsername
             }
             else{
                  this.$notify({
                 message: '很遗憾，您还没注册',
                 });
             } 
         
        })
      }
     } 
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
*{
            margin: 0;
            padding: 0;
        }
         
        .body {
            display: flex;
            align-items: center;
            /* align-content: center; */
            justify-content: center;
            height: 100vh;
            flex-wrap: wrap;
            background-image: url(../assets/4.jpg);
            background-size: cover;
        }
         
        #loginDiv {
            width: 37%;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 300px;
            background-color: rgba(75, 81, 95, 0.3);
            /* background-color: white;
            opacity: 45%; */
            box-shadow: 7px 7px 17px rgba(200, 54, 54, 0.5);
            border-radius: 5px;
        }
         #loginDiv h1{
             position: relative;
             bottom: 2rem;
             left: 5rem;
         }
        #name_trip {
            margin-left: 50px;
            color: red;
        }
         
        p{
            position: relative;
            top: 25px;
           left: -15%;
           
            color: azure;
        }
         
        input {
            margin-left: 15px;
            border-radius: 5px;
            border-style: hidden;
            height: 30px;
            width: 140px;
           background-color: rgba(216, 191, 216, 0.5);
            outline: none;
            color: #f0edf3;
            padding-left: 10px;
        }
         
        .button {
            border-color: cornsilk;
            background-color: rgba(100, 149, 237, .7);
            color: aliceblue;
            border-style: hidden;
            border-radius: 5px;
            width: 100px;
            height: 31px;
            font-size: 16px;
        } 
</style>
